﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SecondTimer
{
    public partial class Form1 : Form
    {
        int minutes, seconds, mseconds;

        public Form1()
        {
            InitializeComponent();
            timer1.Interval = 500;
            minutes = 0;
            seconds = 0;
            mseconds = 0;
            label1.Text = "00";
            label2.Text = "00";
            label3.Text = ":";
            label3.Visible = true;
            button1.Text = "Start";
            button2.Text = "Reset";
            
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (label3.Visible)
            {
                if (seconds < 59)
                {
                    seconds++;
                    if (seconds < 10)
                        label2.Text = "0" + seconds.ToString();
                    else
                        label2.Text = seconds.ToString();
                }
                else
                {
                    if (minutes < 59)
                    {
                        minutes++;
                        if (minutes < 10)
                            label1.Text = "0" + minutes.ToString();
                        else
                            label1.Text = minutes.ToString();
                        seconds = 0;
                        label2.Text = "00";
                    }
                    else
                    {
                        minutes = 0;
                        label1.Text = "00";
                    }
                }
                label3.Visible = false;
            }
            else 
            {
                label3.Visible = true;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (timer1.Enabled)
            {
                timer1.Enabled = false;
                button1.Text = "Start";
                button2.Enabled = true;
            }
            else 
            {
                timer1.Enabled = true;
                button1.Text = "Stop";
                button2.Enabled = false;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            minutes = 0;
            seconds = 0;
            mseconds = 0;
            label1.Text = "00";
            label2.Text = "00";

        }
    }
}
